%% selectTwoPoints
%
% Prompts user to select 2 points in an image and returns point coordinates
%
%% Synatax
%
% [ pointOneCoordinates, pointTwoCoordinates ] = selectTwoPoints( dicomImg, varargin )
%
% [ pointOneCoordinates, pointTwoCoordinates ] = selectTwoPoints( dicomImg )
%
% [ [411, 370, 0, 0], [700, 371, 0 ,0] ] = selectTwoPoints( dicomImg )
%
% [ pointOneCoordinates, pointTwoCoordinates ] = selectTwoPoints( dicomImg, ... 
%                                                                 pointOneDisplayString, ...
%                                                                 pointTwoDisplayString)

% [ [411, 370, 0, 0], [700, 371, 0 ,0] ] = selectTwoPoints( dicomImg, ... 
%                                                           'Please select the first point', ...
%                                                           'Please select the second point')
%
%% Description
%
% Prompts the user to select two points on a 2D image and returns the
% coordinates of those points. Two strins can be optionally provided to be
% displayed to the user instructing them to select the points. 
%
%% Arguments
%* dicomImg                             - Double: An image 
%
%* pointOneDisplayString [OPTIONAL]     - Char: A string to display to the
%                                            user prompting them to select 
%                                            the first point
%
%* pointTwoDisplayString [OPTIONAL]     - Char: A string to display to the
%                                            user prompting them to select 
%                                            the second point
%
%% Returns
%
%* pointOneCoordinates                  - Double: The X and Y coordinates of
%                                                 the first user selected point
%
%* pointTwoCoordinates                  - Double: The X and Y coordinates of
%                                                 the second user selected point
%
%% Function Side Effects
%
%* A figure is displayed
%
%* Text is outputted to the console
%
%* The user is prompted to select points
%
%% Exceptions
%
%* N/A
%
%% See Also
% 

function [ pointOneCoordinates, pointTwoCoordinates ] = selectTwoPoints( dicomImg, pointOneDisplayString, ...
                                                                                    pointTwoDisplayString, ...
                                                                                      instructionText)


assert(isnumeric(dicomImg), 'selectTwoPoints:invalidDicomImgType', ...
    'dicomImg must be numeric');

assert(length(size(dicomImg)) >= 2, 'selectTwoPoints:invalidDicomImgDimensions', ...
    'dicomImg must be at least two dimensional');

assert(isempty(dicomImg) == 0, 'selectTwoPoints:emptyDicomImg', ...
    'dicomImg cannot be empty');


imshow(dicomImg);

hold on

set(instructionText, 'string', strcat('Please select a large hashmark starting the respective one second interval.'));

if strcmp(pointOneDisplayString, 'NA') == 0
    
    disp(pointOneDisplayString);
    
end 

pointOneCoordinates = getrect();

set(instructionText, 'string', strcat('Please select a large hashmark ending the respective one second interval.'));

if strcmp(pointTwoDisplayString, 'NA') == 0
    
    disp(pointTwoDisplayString);
    
end 

pointTwoCoordinates = getrect();

hold off

end

